import java.util.ArrayList;
import java.util.List;
import java.util.Random;

abstract class Shp {
    public abstract void calculateArea(); // 纯虚函数，确保派生类必须实现此函数
}

class Circle extends Shp {
    private double r;

    public Circle(double radius) {
        this.r = radius;
    }

    @Override
    public void calculateArea() {
        System.out.println("S(circle)=" + r * r * Math.PI);
    }
}

class Rectangle extends Shp {
    private double a, b;

    public Rectangle(double length, double width) {
        this.a = length;
        this.b = width;
    }

    @Override
    public void calculateArea() {
        System.out.println("S(rectangle)=" + a * b);
    }
}

public class Shape { // 主类名保持为 Shape
    public static void main(String[] args) {
        Random rand = new Random(); // 初始化随机数生成器
        List<Shp> shapes = new ArrayList<>(); // 创建一个Shp对象列表

        // 随机添加Circle和Rectangle对象
        for (int i = 0; i < 10; ++i) {
            if (rand.nextBoolean()) { // 如果随机数为true，创建Circle
                double radius = rand.nextInt(10) + 1; // 随机半径
                shapes.add(new Circle(radius));
            } else { // 如果随机数为false，创建Rectangle
                double length = rand.nextInt(10) + 1; // 随机长度
                double width = rand.nextInt(10) + 1; // 随机宽度
                shapes.add(new Rectangle(length, width));
            }
        }

        // 计算每个形状的面积
        for (Shp shape : shapes) {
            shape.calculateArea();
        }
    }
}
